package com.shao.dao;


import com.shao.bean.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author: com.song shao
 * @date: 2022/2/26
 * @time: 8:21
 * @version: 1.0
 */
@SuppressWarnings("all")
public interface stuLoginDao {

    /**
     * 查询账号的状态
     *
     * @param name
     * @return
     */
    @Select("select  * from student where stu_username= #{name}")
    student findStas(@Param("name") String name);

    /**
     * 查询学生详情表中的数据
     *
     * @param key
     * @return
     */
    @Select("select * from stu_info where stu_detail = #{stu_detail};")
    List<stu_info> findStuData(@Param("stu_detail") String stu_detail);

    /**
     * 查询学生所在的班级
     *
     * @param stu_class_id
     * @return
     */
    @Select("select * from cls where class_id = #{stu_class_id};")
    cls findClass(@Param("stu_class_id") int stu_class_id);

    /**
     * 拿到当前id的学科详情表
     *
     * @param stu_subject_id
     * @return
     */
    @Select("select * from subject where subject_id = #{stu_subject_id}")
    subject findStuSubData(@Param("stu_subject_id") int stu_subject_id);

    /**
     * 查询当前的班主任
     *
     * @param stu_class_id
     * @return
     */
    @Select("select * from teacher where tea_class = #{stu_class_id}")
    teacher selectTeacher(@Param("stu_class_id") int stu_class_id);

    /**
     * 管理员的钩子函数调用的学生表中的信息
     *
     * @return
     */
    @Select("select * from  student")
    List<student> findStudentList();

    /**
     * @param stu_username
     */
    @Update("update student set stu_state=#{kry} where stu_username = #{stu_username}")
    int updataStatus(@Param("stu_username") String stu_username, @Param("kry") int kry);

    /**
     * 查询老师
     *
     * @param stu_username1
     * @return
     */
    @Select("select * from student  where stu_username = #{stu_username1}")
    student findStudent(@Param("stu_username1") String stu_username1);

    /**
     * 教师查询学生
     *
     * @return
     */
    @Select("select * from student")
    List<student> findStu();

    /**
     * 根据学科的名字更改学科的总分
     *
     * @param subject_name
     * @param subject_total_points
     * @return
     */
    @Update("update subject set subject_total_points= #{subject_total_points} where subject_name = #{subject_name}")
    int updateSubjectByName(@Param("subject_name") String subject_name, @Param("subject_total_points") int subject_total_points);

    /**
     * 根据学科的名字和学科的总分进行查询学科
     *
     * @param subject_name
     * @return
     */
    @Select("select  * from subject where subject_name = #{subject_name}")
    subject findBySubjectDate(@Param("subject_name") String subject_name);

    /**
     * 修改个人成绩
     *
     * @param stu_score
     * @param subject_id
     * @return
     */
    @Update("update stu_info set stu_score = #{stu_score} where stu_subject_id = #{subject_id}")
    int updataStudentScore(@Param("stu_score") int stu_score, @Param("subject_id") int subject_id);
}
